var webAddress = 'http://fxapp.1024wl.cn';
var codeSecond = '';
var token='dxgANYXU4RqrAXo6OVwmBc9oodHWNXG2';
var limit = 10;



var iosNarHeight;
apiready = function() {
    var deviceModel = api.deviceModel;
    if (deviceModel.indexOf('iPhone10') > -1) {
        iosNarHeight = 80;
    } else {
        iosNarHeight = 50;
    }


    var header = document.querySelector('#topbar');
    $api.fixStatusBar(header);

};

//强制保留2位
function toDecimal2(x) {
    var f = parseFloat(x);
    if (isNaN(f)) {
        return false;
    }
    var f = Math.round(x * 100) / 100;
    var s = f.toString();
    var rs = s.indexOf('.');
    if (rs < 0) {
        rs = s.length;
        s += '.';
    }
    while (s.length <= rs + 2) {
        s += '0';
    }
    return s;
}


// 格式化金额
function outputmoney(number) {
    if (number) {
        number = number.toString();
        number = number.replace(/\,/g, "");
        if (isNaN(number) || number == "") return "";
        number = Math.round(number * 100) / 100;
        if (number < 0)
            return '-' + outputdollars(Math.floor(Math.abs(number) - 0) + '') + outputcents(Math.abs(number) - 0);
        else
            return outputdollars(Math.floor(number - 0) + '') + outputcents(number - 0);
    } else {
        // alert(2);
        return '0.00';
    }
}

function outputdollars(number) {
    if (number.length <= 3)
        return (number == '' ? '0' : number);
    else {
        var mod = number.length % 3;
        var output = (mod == 0 ? '' : (number.substring(0, mod)));
        for (i = 0; i < Math.floor(number.length / 3); i++) {
            if ((mod == 0) && (i == 0))
                output += number.substring(mod + 3 * i, mod + 3 * i + 3);
            else
                output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
        }
        return (output);
    }
}

function outputcents(amount) {
    amount = Math.round(((amount) - Math.floor(amount)) * 100);
    return (amount < 10 ? '.0' + amount : '.' + amount);
}

// 隐藏姓名
function hidden_name(str) {
    var len = str.length;
    var tmp = '';
    for (var i = 0; i < len - 1; i++) {
        tmp += '**';
    }
    var name = str.substr(str.length - 1, 1);
    tmp += name;
    return tmp;
}

// 隐藏手机号码
function hidden_phonenumber(str) {
    var len = str.length;
    var tou = str.substr(0, 3);
    var wei = str.substr(len - 4, 4);
    var tmp = tou + "****" + wei;
    return tmp;
}

// 时间戳转化为datetime格式
/*
function getDate(time){
    // 获取带时区的格式
    var timestamp = new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
    d = new Date(timestamp);
    var year=d.getFullYear();

    var month=d.getMonth()+1;
    if (month < 10) {
    	month = '0'+month;
    }
    var date=d.getDate();
    if (date < 10) {
    	date = '0'+date;
    }
    var hour=d.getHours();
    if (hour < 10) {
    	hour = '0'+hour;
    }
    var minute=d.getMinutes();
    if (minute < 10) {
    	minute = '0'+minute;
    }
    var second=d.getSeconds();
    if (second < 10) {
    	second = '0'+second;
    }
    return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}
*/

// 时间戳转化为datetime格式
function getDate(nS) {
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
